from rest_framework.filters import BaseFilterBackend

class IsOwnerFilterBackend(BaseFilterBackend):
    """
    仅允许用户查看自己对象的过滤器。
    """

    def filter_queryset(self, request, queryset, view):
        return queryset.filter(owner=request.user)
